{{extend 'layout.html'}}

<h2 class="fancy">PyForum Administration - Manage Administration Messages</h2>

{{include 'fadmin/admin_options.html'}}

{{if messages:}}
    <form id="msg_form" method="post" action="">
        <fieldset id="msg_form_fields">
            <input type="hidden" id="form_submitted" name="form_submitted" value="1" />

            <table class="bordered" style="width: 100%;">
                <thead>
                    <tr>
                        <th>&nbsp;</td>
                        <th>From</td>
                        <th>Subject</th>
                        <th>Message</th>
                        <th>Date</th>
                    </tr>
                </thead>
                <tbody>
                    {{for idx, message in enumerate(messages):}}
                        <tr>
                            <td style="text-align: center;">
                                <input type="checkbox" id="msg_id_{{=message.id}}" name="msg_id_{{=message.id}}" value="{{=message.id}}" />
                            </td>
                            <td style="text-align: center;">
                                {{if message.user_id:}}
                                    <a href="{{=URL(r=request, c='pm', f='message_new', args=[message.user_id])}}"
                                    title="View Message" class="linkb">{{=forumhelper.get_display_name(message.user_id)}}</a>
                                {{else:}}
                                    <b>Anonymous User</b>
                                {{pass}}
                            </td>
                            <td>{{=message.subject}}</a></td>
                            <td>{{=message.msg}}</a></td>
                            <td style="text-align: center;">{{=message.creation_date.strftime('%d/%m/%Y')}}</td>
                        </tr>
                    {{pass}}
                </tbody>
            </table>

            <div class="both-separator">
                <input type="submit" id="read_b" name="read_b" value="Remove from list" />
                {{if view_info['purge']:}}
                    <input type="submit" id="purge_b" name="purge_b" value="Purge DB ({{=view_info['purge']}})"
                    onclick="return confirm('Please Confirm');" />
                {{pass}}
            </div>

        </fieldset>
    </form>
{{else:}}
    <p class="warning">No messages intended for administrators were found.</p>
    {{if view_info['purge']:}}
        <form id="msg_form" method="post" action="">
            <fieldset id="msg_form_fields">
                <input type="hidden" id="form_submitted" name="form_submitted" value="1" />
                <input type="submit" id="purge_b" name="purge_b" value="Purge DB ({{=view_info['purge']}})"
                onclick="return confirm('Please Confirm');" />
            </fieldset>
        </form>
    {{pass}}
{{pass}}
